home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / tcl / tcl70b2.lha / tcl7.0b2 / tests / eval.test < prev    next >
Text File  |  1993-02-06  |  2KB  |  70 lines

  1. # Commands covered:  eval
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1991-1993 The Regents of the University of California.
  8. # All rights reserved.
  9. #
  10. # Permission is hereby granted, without written agreement and without
  11. # license or royalty fees, to use, copy, modify, and distribute this
  12. # software and its documentation for any purpose, provided that the
  13. # above copyright notice and the following two paragraphs appear in
  14. # all copies of this software.
  15. #
  16. # IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17. # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18. # OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19. # CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. #
  21. # THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23. # AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24. # ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25. # PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26. #
  27. # $Header: /user6/ouster/tcl/tests/RCS/eval.test,v 1.5 93/02/06 15:54:14 ouster Exp $ (Berkeley)
  28.  
  29. if {[string compare test [info procs test]] == 1} then {source defs}
  30.  
  31. test eval-1.1 {single argument} {
  32.     eval {format 22}
  33. } 22
  34. test eval-1.2 {multiple arguments} {
  35.     set a {$b}
  36.     set b xyzzy
  37.     eval format $a
  38. } xyzzy
  39. test eval-1.3 {single argument} {
  40.     eval concat a b c d e f g
  41. } {a b c d e f g}
  42.  
  43. test eval-2.1 {error: not enough arguments} {catch eval} 1
  44. test eval-2.2 {error: not enough arguments} {
  45.     catch eval msg
  46.     set msg
  47. } {wrong # args: should be "eval arg ?arg ...?"}
  48. test eval-2.3 {error in eval'ed command} {
  49.     catch {eval {error "test error"}}
  50. } 1
  51. test eval-2.4 {error in eval'ed command} {
  52.     catch {eval {error "test error"}} msg
  53.     set msg
  54. } {test error}
  55. test eval-2.5 {error in eval'ed command: setting errorInfo} {
  56.     catch {eval {
  57.     set a 1
  58.     error "test error"
  59.     }} msg
  60.     set errorInfo
  61. } "test error
  62.     while executing
  63. \"error \"test error\"\"
  64.     (\"eval\" body line 3)
  65.     invoked from within
  66. \"eval {
  67.     set a 1
  68.     error \"test error\"
  69.     }\""
  70.